package com.atguigu.flink.streamapi.source;

import com.alibaba.fastjson.JSON;
import com.atguigu.flink.pojo.ChannelData;
import com.atguigu.flink.streamapi.exec.MySource;
import org.apache.commons.lang3.RandomUtils;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;

/**
 * Created by Smexy on 2022/11/21
 *
 *  用不到
 *
 *
 *  模拟一个Source，会每隔500ms，产生 一条
 *      { userId:100,behavior:"uninstall","channel":"ZTE",timestamp:xxx  }
 *
 * 其中behavior和channel来自如下枚举:
 *  behavior: "install","uninstall","download","update"
 *  channel:"ZTE","APPLE","HUAWEI","MI","VIVO","OPPO"
 */
public class Demo5_Custom
{
    public static void main(String[] args) {
        
        
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        /*
                SourceFunction 类型返回的是 非并行的Source，它的并行度只能是1！
                如果希望创建并行的Source，需要实现 ParallelSourceFunction
         */
        env.addSource(new MySource()).setParallelism(2)
           .print();
        
        try {
                    env.execute();
                } catch (Exception e) {
                    e.printStackTrace();
                }
        
    }

    //定义一个类，集成Source的功能
    //public static class MySource implements SourceFunction<String>{

}
